home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / GameKit / gamekit-1 / GKText.psw < prev    next >
Text File  |  1995-06-12  |  1KB  |  58 lines

  1.  
  2. defineps GKTextSetUp ( )
  3.  
  4. % define the functions here so that there is less to send between
  5. % the gamekit and the postscript server.  This will hopefully make
  6. % drawing text a hair faster and it's easy enough to set up...
  7.  
  8. /gkbbox {
  9.     /str 2 1 roll def
  10.     newpath
  11.     % start at origin; get both bounding boxes
  12.     0 0 moveto (str) false charpath
  13.     2 2 moveto (str) false charpath
  14.     pathbbox
  15.     % convert MAX corner into width/heights and add 1 to
  16.     % width/height (compensates for adjustment below)
  17.     exch 3 index sub 1 add exch 2 index sub 1 add
  18.     % move min corner down & left 1 unit (covers rounding)
  19.     4 2 roll 1 sub 4 1 roll 1 sub 4 1 roll
  20.     % return the values on the stack... x y width height
  21.     height width y x
  22. } def
  23.  
  24. /gkdrawtext {
  25.     /str 2 1 roll def
  26.     /ylate 2 1 roll def
  27.     /xlate 2 1 roll def
  28.     gsave
  29.         0.0 setgray
  30.         xlate 1 sub ylate 1 add moveto (str) show
  31.         xlate 1 sub ylate 1 sub moveto (str) show
  32.         xlate 1 add ylate 1 add moveto (str) show
  33.         xlate 1 add ylate 1 sub moveto (str) show
  34.         1.0 setgray
  35.         xlate ylate moveto (str) show
  36.     grestore
  37. } def
  38.  
  39. endps
  40.  
  41.  
  42. defineps GKborderedTextBoundingBox( char *str; | float *x; float *y; float *width; float *height )
  43.  
  44. % you must have called the set up routine first!
  45. gsave
  46.     str gkbbox height width y x
  47. grestore
  48.  
  49. endps
  50.  
  51.  
  52. defineps GKdrawBorderedText( float xlate; float ylate; char *str )
  53.  
  54. % you must have called the set up routine first!
  55. xlate ylate str gkdrawtext
  56.  
  57. endps
  58.